;(function(FormBase) {
    FormBase.Username = FormBase.extend({
        msgObj: { // error msg
            NOT_EMPTY: "请填写用户名",
            USERNAME_LENGTH: "用户名长度为4~20位字符",
            USERNAME_LIMIT: "用户名只能包含英文、数字、“-”、“_”",
            START_RULE: "用户名不能以符号开头"
        },
        susFun: function() {},
        errFun: function() {},
        checkForm: function() {
            var regNum = /^\d{1,6}$/;
            var regNum1 = /[a-zA-Z0-9_\-]{4,20}/;

            var reg1 = /^[_\-][a-zA-Z0-9_\-]+$/,
                reg2 = /^[a-zA-Z0-9_\-]+$/,
                reg3 = /^[0-9]*$/;
            if (this.newValue) {
                if (reg1.test(this.newValue)) {
                    return {
                        status: false,
                        msg: this.getMsg("START_RULE"),
                        value: this.newValue
                    };
                } else if (!reg2.test(this.newValue) || reg3.test(this.newValue)) {
                    return {
                        status: false,
                        msg: this.getMsg("USERNAME_LIMIT"),
                        value: this.newValue
                    };
                } else if (this.newValue.length < 4 || this.newValue.length > 20) {
                    return {
                        status: false,
                        msg: this.getMsg("USERNAME_LENGTH"),
                        value: this.newValue
                    };
                } else {
                    return {
                        status: true,
                        msg: null,
                        value: this.newValue
                    };
                }
            } else {
                return {
                    status: false,
                    msg: null,
                    value: this.newValue
                };
            }
        }

    });
})(window.FormBase = window.FormBase || {})
